﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MySql.Data.MySqlClient;

/// <summary>
/// Summary description for StockInformation
/// </summary>
public class StockInformation
{
  private const string STORED_PROCEDURE = "StockInformation_Get";
  DatabaseManager db;
  MySqlDataReader reader;

  public string Id { get; set; }
  public int Year { get; set; }
  public int SharePrice { get; set; }
  public int NumberOfShares { get; set; }
  public int CashFlowFromOperatingActivities { get; set; }

	public StockInformation()
	{
    db = new DatabaseManager();
	}

  public void Load(string id, int year)
  {
    db.AddParameter("@id", id);
    db.AddParameter("@year", year);
    using (reader = db.ExecuteStoredProcedure(STORED_PROCEDURE))
    {
      while (reader.Read())
      {
        Id = reader.GetString("id").ToString();
        Year = Convert.ToInt32(reader.GetString("year"));
        SharePrice = Convert.ToInt32(reader.GetString("share_price"));
        NumberOfShares = Convert.ToInt32(reader.GetString("number_of_shares"));
        CashFlowFromOperatingActivities = Convert.ToInt32(reader.GetString("cash_flow_from_operating_activities"));
      }
    }
  }
}